package com.ruoyi.business.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.BusAcquisitionCardChannel;
import com.ruoyi.business.service.IBusAcquisitionCardChannelService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 采集卡通道Controller
 * 
 * @author asher
 * @date 2021-11-03
 */
@RestController
@RequestMapping("/business/channel")
public class BusAcquisitionCardChannelController extends BaseController
{
    @Autowired
    private IBusAcquisitionCardChannelService busAcquisitionCardChannelService;

    /**
     * 查询采集卡通道列表
     */
    @PreAuthorize("@ss.hasPermi('business:channel:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusAcquisitionCardChannel busAcquisitionCardChannel)
    {
        startPage();
        List<BusAcquisitionCardChannel> list = busAcquisitionCardChannelService.selectBusAcquisitionCardChannelList(busAcquisitionCardChannel);
        return getDataTable(list);
    }

    /**
     * 导出采集卡通道列表
     */
    @PreAuthorize("@ss.hasPermi('business:channel:export')")
    @Log(title = "采集卡通道", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BusAcquisitionCardChannel busAcquisitionCardChannel)
    {
        List<BusAcquisitionCardChannel> list = busAcquisitionCardChannelService.selectBusAcquisitionCardChannelList(busAcquisitionCardChannel);
        ExcelUtil<BusAcquisitionCardChannel> util = new ExcelUtil<BusAcquisitionCardChannel>(BusAcquisitionCardChannel.class);
        return util.exportExcel(list, "采集卡通道数据");
    }

    /**
     * 获取采集卡通道详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:channel:query')")
    @GetMapping(value = "/{channelId}")
    public AjaxResult getInfo(@PathVariable("channelId") Long channelId)
    {
        return AjaxResult.success(busAcquisitionCardChannelService.selectBusAcquisitionCardChannelByChannelId(channelId));
    }

    /**
     * 新增采集卡通道
     */
    @PreAuthorize("@ss.hasPermi('business:channel:add')")
    @Log(title = "采集卡通道", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusAcquisitionCardChannel busAcquisitionCardChannel)
    {
        return toAjax(busAcquisitionCardChannelService.insertBusAcquisitionCardChannel(busAcquisitionCardChannel));
    }

    /**
     * 修改采集卡通道
     */
    @PreAuthorize("@ss.hasPermi('business:channel:edit')")
    @Log(title = "采集卡通道", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusAcquisitionCardChannel busAcquisitionCardChannel)
    {
        return toAjax(busAcquisitionCardChannelService.updateBusAcquisitionCardChannel(busAcquisitionCardChannel));
    }

    /**
     * 删除采集卡通道
     */
    @PreAuthorize("@ss.hasPermi('business:channel:remove')")
    @Log(title = "采集卡通道", businessType = BusinessType.DELETE)
	@DeleteMapping("/{channelIds}")
    public AjaxResult remove(@PathVariable Long[] channelIds)
    {
        return toAjax(busAcquisitionCardChannelService.deleteBusAcquisitionCardChannelByChannelIds(channelIds));
    }
}
